package com.aizuda.oss.model;

import com.aizuda.oss.platform.AliyunOss;
import lombok.Getter;

import java.util.Objects;

/**
 * 文件存储平台
 *
 * @author hubin
 * @since 2022-03-29
 */
@Getter
public enum StoragePlatform {

    aliyun(AliyunOss.class);

    private final Class ossStrategy;

    StoragePlatform(Class ossStrategy) {
        this.ossStrategy = ossStrategy;
    }

    public static Class getStrategyClass(String name) {
        for (StoragePlatform ossEnum : values()) {
            if (Objects.equals(ossEnum.name(), name)) {
                return ossEnum.getOssStrategy();
            }
        }
        throw new RuntimeException("暂不支持存储平台: " + name);
    }
}
